package com.itwang.common;


import com.itwang.handler.ConsumerException;

import java.io.*;
import java.util.Properties;

//properties文件读取工具
public class PropertiesUtil {
	private static Properties properties = new Properties();
	private static String path = "config.properties";
	static {
		try {
			properties = read(path);
		} catch (IOException e) {
			throw new ConsumerException(e);
		}
	}
	
	public static Properties read(String path) throws IOException {
		//项目中配置文件的位置
		File file = new File("配置文件放在这里.jpg");
		if (!file.exists()) {
			file.createNewFile();
		}
		
		
		FileInputStream fileInputStream = new FileInputStream(path);
		InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream,"utf-8");
		BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
		properties.load(bufferedReader);
		return properties;
	}
	
	public static String getKey(String key) {
		return properties.getProperty(key);
	}
}
